package com.advaita.util;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;

public class ComboRenderer extends JLabel implements ListCellRenderer {

	public ComboRenderer() {
		// The combo boxes don't highlight properly because we are using nimbus
		// and probably java 1.6
		// Need to try with java 1.7 to see if they fixed the bug
		// or try another work around.  
        setOpaque(true);  
      setBorder(new EmptyBorder(1, 1, 1, 1));  
       
		
	}

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		if (isSelected) {
			setBackground(list.getSelectionBackground());
			setForeground(list.getSelectionForeground());

		} else {
			setBackground(list.getBackground());
			setForeground(list.getForeground());

		}
		if (!((CanEnable) value).isEnabled()) {
			setBackground(list.getBackground());
			setForeground(UIManager.getColor("Label.disabledForeground"));
		}

		
		setText((value == null) ? "" : value.toString());
		return this;
	}
}